cmake_minimum_required (VERSION 2.6)

SET(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})

PROJECT (PipelineDP)

#SET (CMAKE_BUILD_TYPE Release)
########################################################
# Files

SET (pldp_MOC_HDRS

        pldp.h

        domainmodel/altrefmeasure.h
        domainmodel/apdmobject.h
        domainmodel/centerlineobject.h
        domainmodel/centerlinepoint.h
        domainmodel/centerlinepolyline.h
        domainmodel/centerlinepolylineevent.h
        domainmodel/controlpoint.h
        domainmodel/fitting.h
        domainmodel/lineloop.h
        domainmodel/linelooppassport.h
        domainmodel/nonfacilityobject.h
        domainmodel/objectarchive.h
        domainmodel/onlinefacility.h
        domainmodel/onlinefeature.h
        domainmodel/onlinepointfacility.h
        domainmodel/onlinepolyline.h
        domainmodel/onlinepolylinefacility.h
        domainmodel/onlinepolylineforofflinefeature.h
        domainmodel/offlinefacility.h
        domainmodel/site.h
        domainmodel/stationseries.h
        domainmodel/subsystem.h

        forms/hierarchyview.h
        forms/linelooppassportgui.h
        forms/listchoose.h
        forms/listwidget.h
        forms/pipelineform.h
        forms/profileview.h
        forms/tabbuilder.h

        forms/treemodel/pipenodes.h
        forms/treemodel/treemodel.h
        forms/treemodel/treenode.h

        #pgconnection/pgeditconnection.cpp
        #pgconnection/pgselectconnection.cpp

        general/datechoose.h
        general/dbconnection.h
        general/customrelationmodel.h
        general/framechoose.h
        general/psqlenumdelegate.h
        general/qsql_psql.h
        general/tunetablemodel.h
        general/unique.h
)

SET (pldp_SRCS

        pldp.cpp

        domainmodel/altrefmeasure.cpp
        domainmodel/apdmobject.cpp
        domainmodel/centerlinepoint.cpp
        domainmodel/centerlineobject.cpp
        domainmodel/centerlinepolyline.cpp
        domainmodel/centerlinepolylineevent.cpp
        domainmodel/controlpoint.cpp
        domainmodel/fitting.cpp
        domainmodel/lineloop.cpp
        domainmodel/linelooppassport.cpp
        domainmodel/nonfacilityobject.cpp
        domainmodel/objectarchive.cpp
        domainmodel/onlinefacility.cpp
        domainmodel/onlinefeature.cpp
        domainmodel/onlinepointfacility.cpp
        domainmodel/onlinepolyline.cpp
        domainmodel/onlinepolylinefacility.cpp
        domainmodel/onlinepolylineforofflinefeature.cpp
        domainmodel/offlinefacility.cpp
        domainmodel/site.cpp
        domainmodel/stationseries.cpp
        domainmodel/subsystem.cpp

        forms/hierarchyview.cpp
        forms/linelooppassportgui.cpp
        forms/listchoose.cpp
        forms/listwidget.cpp
        forms/pipelineform.cpp
        forms/profileview.cpp
        forms/tabbuilder.cpp

        forms/treemodel/pipenodes.cpp
        forms/treemodel/treemodel.cpp
        forms/treemodel/treenode.cpp

        #pgconnection/pgeditconnection.cpp
        #pgconnection/pgselectconnection.cpp

        general/datechoose.cpp
        general/dbconnection.cpp
        general/customrelationmodel.cpp
        general/framechoose.cpp
        general/psqlenumdelegate.cpp
        general/qsql_psql.cpp
        general/tunetablemodel.cpp
        general/unique.cpp
)

SET (pldp_UIS

        forms/hierarchyview.ui
        forms/linelooppassportguibase.ui
        forms/listchoose.ui
        forms/listwidget.ui
        forms/pipelineform.ui
        forms/profileview.ui

        general/datechoose.ui
        general/framechoose.ui
        #pgconnection/pgeditconnection.ui
        #pgconnection/pgselectconnection.ui
)

SET (pldp_RCCS  pldp.qrc)

########################################################
# Build
set (QT_USE_QT3SUPPORT FALSE)
set (QT_USE_QTGUI TRUE)
set (QT_USE_QTSQL TRUE)
set (QT_USE_QTSVG TRUE)
set (QT_USE_QTXML TRUE)
set (QT_USE_QTNETWORK TRUE)
set (QT_USE_QAXCONTAINER TRUE)


FIND_PACKAGE (Qt4 REQUIRED)
FIND_PACKAGE (QGIS REQUIRED)
FIND_PACKAGE (Postgres REQUIRED)
IF (NOT QGIS_FOUND)
  MESSAGE (SEND_ERROR "QGIS dependency was not found!")
ENDIF (NOT QGIS_FOUND)

IF(NOT QT_QAXCONTAINER_INCLUDE_DIR)
  FIND_PATH(QT_QAXCONTAINER_INCLUDE_DIR QAxObject "$ENV{OSGeo4W_ROOT}/include/qt4/ActiveQt/")
ENDIF(NOT QT_QAXCONTAINER_INCLUDE_DIR)
MESSAGE(STATUS "Found ActiveQt: ${QT_QAXCONTAINER_INCLUDE_DIR}")

IF (WIN32)
  # expect that classes are being imported by default
  # Note: MSVC doesn't like when the macros are quotes
  # and MSYS doesn't like them unqouted (bacause of braces)
  # import qgis classes
  IF (MSVC)
    ADD_DEFINITIONS("-DGUI_EXPORT=__declspec(dllimport)")
    ADD_DEFINITIONS("-DCORE_EXPORT=__declspec(dllimport)")
  ELSE (MSVC)
    ADD_DEFINITIONS("\"-DGUI_EXPORT=__declspec(dllimport)\"")
    ADD_DEFINITIONS("\"-DCORE_EXPORT=__declspec(dllimport)\"")
  ENDIF (MSVC)
ELSE (WIN32)
  ADD_DEFINITIONS(-DGUI_EXPORT=)
  ADD_DEFINITIONS(-DCORE_EXPORT=)
ENDIF (WIN32)

INCLUDE (${QT_USE_FILE})

if (MSVC)
	add_definitions (/W3)
elseif (CMAKE_COMPILER_IS_GNUCXX)
	add_definitions (/Wall -pedantic)
else ()
	message ("Unknown compiler")
endif ()

QT4_WRAP_UI (pldp_UIS_H  ${pldp_UIS})

QT4_WRAP_CPP (pldp_MOC_SRCS  ${pldp_MOC_HDRS})

QT4_ADD_RESOURCES(pldp_RCC_SRCS ${pldp_RCCS})

ADD_LIBRARY (pldpplugin MODULE ${pldp_SRCS} ${pldp_MOC_SRCS} ${pldp_RCC_SRCS} ${pldp_UIS_H})

INCLUDE_DIRECTORIES(
     ${CMAKE_CURRENT_BINARY_DIR}
     ${CMAKE_CURRENT_SOURCE_DIR}     
     ${QGIS_INCLUDE_DIR}
     ${POSTGRES_INCLUDE_DIR}        
     ${QT_QAXCONTAINER_INCLUDE_DIR}
     domainmodel
     forms
     forms/treemodel
     general
)

TARGET_LINK_LIBRARIES(pldpplugin
	${QT_LIBRARIES}
	${POSTGRES_LIBRARY}
	${QGIS_CORE_LIBRARY}
    ${QGIS_GUI_LIBRARY}
)


########################################################
# Install

INSTALL(TARGETS pldpplugin
  RUNTIME DESTINATION ${QGIS_PLUGIN_DIR}
  LIBRARY DESTINATION ${QGIS_PLUGIN_DIR})

